from flask import render_template, make_response, request
from flask_restful import Resource, reqparse
from app.commons.check_token import checkIfLogin
import urllib.parse

parser = reqparse.RequestParser(trim=True)


class AdminView(Resource):
    def get(self):
        try:
            cookie = urllib.parse.unquote(str(request.cookies.get('pj_login')))
            if checkIfLogin(cookie):
                return make_response(render_template('index.html'), 200)
            else:
                return make_response(render_template('/LoginPage/index.html'), 200)
        except:
            return {"err_msg": 404}
